<include file="Public/head" title="实名认证-基本信息"/>
<include file="Public/back_head"/>
<div class="main">
    <div class="Real_name">
        <form onsubmit="return false;">
            <label for=""><span>旧手机号</span><input type="text" value="{$user.mobile}"></label>
            <label for="">
                <span>新手机号</span><input type="tel" placeholder="18335155556" maxlength="11" id="tel">
                <i class="get_code">获取验证码</i>
            </label>
            <label for=""><span>验证码</span><input type="number" id="yzm" placeholder="请输入手机短信验证码" ></label>
            <button class="btn">确定</button>
        </form>
    </div>
</div>
<!-- http://www.baidu.com?number=xxxx&order_id=1222 -->
<script type="text/javascript">
    (function () {
        //       放弃填写
//         $(".Return").click(function () {
//             Establish_backout("温馨提示","是否放弃实名认证,<br> 放弃后无法设置收货地址","放弃","继续设置","基本信息-信息认证.html");
//         });
        $("body").on("click",".Position_close",function () {
            $(".back-out").hide();
        });
        $("body").on("click",".b2",function () {
            $(".back-out").hide();
        });
        //       放弃填写
        $(function () {
            //验证手机号
            $('#tel').focus(function(){

            }).blur(function() {
                var str=$(this).val();
                if(!(/^1[7|3|4|5|8][0-9]\d{8}$/.test(str))){
                    layer.msg("请输入正确的手机号");
                    return false;
                }
            });
            $("#yzm").focus(function(){

            }).blur(function(){
                if($("input").val()!=""){
                    $(".btn").removeAttr("disabled")
                }
            })
            var flag=true;
            $(".get_code").click(function () {
                var tel= $('#tel').val();
                 if(!(/^1[7|3|4|5|8][0-9]\d{8}$/.test(tel))){
                    layer.msg("请输入正确的手机号");
                    return false;
                }
                if(flag){
                    flag=false;
                    var num = 61;
                    var that = this;
                    setInterval(function () {
                        num--;
                        if (num < 0) {
                            $(that).html("获取验证码");
                            flag=true;
                            return false;
                        }
                        $(that).html(num + "S");
                    }, 1000)
                    $.post(
                        "{:U('getSmsCode')}",
                        {phone:tel},
                        function(data){
                        }
                    )
                }
            });

            $('.btn').click(function(){
                var phone = $('#tel').val();
                var code = $('#yzm').val();
               
                if(code ==''){
                    layer.msg('请输入验证码');
                    return false;
                }
                 $.post(
                        "{:U('save_phone')}",
                        {phone:phone,code:code},
                        function(data){
                            if(data.status == '1'){
                                layer.msg(data.info);
                                setTimeout("location.href='"+data.url+"'",1000);
                            }else{
                                layer.msg(data.info);
                            }
                        }
                    )

            });

        })
    })(jQuery)
</script>
<include file="Public/foot"/>